<layout name="popup" />
<block name="content">
	<input id="val" name="val" type="hidden">
	<input id="name" name="name" type="hidden">
	<div class="popup-frame">
		<div class="popup-header ">
			<div class="pull-left">
				<h1>请选择</h1>
			</div>
			<div class="pull-right">
				<a id="btn_save" class="btn">确定</a>
				<a id='btn_close' class="btn btn-return">关闭</a>
			</div>
		</div>
		<div class="popup-body">
			<div class="popup-body-scroll">
				<div class="popup-content">
					<div class="popup_tree_menu">
						<ul class="tree_menu">
							{$menu}
						</ul>
					</div>
				</div>
			</div>
		</div>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
		var index = parent.layer.getFrameIndex(window.name);
		layui.use(['global'], function() {
			var $ = layui.jquery;
			

			$(".popup_tree_menu a").click(function() {
				$("#val").val($(this).attr("node"));
				$("#name").val($(this).children("span").text());
				$(".popup_tree_menu .tree_menu  a.active").removeClass("active");
				$(this).addClass("active");
			});

			//保存后关闭
			$('#btn_save').on('click', function() {

				if ($("#name").val().length > 0) {

					$val = $("#val").val();
					$name = $("#name").val();									
					
					$field_name = '#udf_field_{$id}_name';
					$field_val = '#udf_field_{$id}_val';

					$($field_name, parent.document).val($name);
					$($field_val, parent.document).val($val);
				} else {
					layer.msg("请选择数据");
					return false;
				}
				parent.layer.close(index);

			});
			//关闭iframe
			$('#btn_close').click(function() {
				parent.layer.close(index);
			});
		});
	</script>
</block>
